<?php
// +---------------------------------------------------------------------+
// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/OneBase                      |
// +---------------------------------------------------------------------+

namespace app\common\model;


/**
 * Game模型
 */
class Game extends ModelBase
{

    protected $insert = ['create_time'];




    /**
     * 时间自动完成
     */
    public function setCreateTimeAttr()
    {

        return TIME_NOW;
    }

    /**
     * logo
     */
    public function getImageAttr()
    {
        return get_picture_url($this->cover_id,false);
    }

    /**
     * logo
     */
    public function getTopImageAttr()
    {
        return get_picture_url($this->top_cover_id,false);
    }

    public function  getNameAttr($value){

        if( isset($_REQUEST['lang']) && $_REQUEST['lang']!='zh-cn' &&  $_REQUEST['lang'] ){

            return   baidu_translate($value);
        }

        return $value;

    }

    public function  getIntroAttr($value){
        if(isset($_REQUEST['lang']) && $_REQUEST['lang']!='zh-cn' &&  $_REQUEST['lang'] ){
            return   baidu_translate($value);
        }

        return $value;

    }

    public function  getContentAttr($value){
        if(isset($_REQUEST['lang']) && $_REQUEST['lang']!='zh-cn' &&  $_REQUEST['lang'] ){
            return   baidu_translate($value);
        }
        return $value;

    }

    /**
     * 连分类表
     */
    public function cate(){
        return $this->belongsTo('GameCategory','category_id','id');
    }

}
